Ext.ux.ViewLink = Ext.extend(Ext.Window, {
	idString:'',
	initComponent : function(config) {
		var linedata = Ext.getCmp(this.idString).getStore()
				.getAt(Ext.getCmp(this.idString).getSelectionModel().lastActive);
		
		var modifyForm = new Ext.FormPanel({
        	labelWidth : 100, // label settings here cascade unless overridden
			autoScroll:true,
			frame : true,
			region : 'center',
			border:true,
			fileUpload: true,
			bodyStyle : 'padding:5px 5px 0',
			width : '100%',
			defaults : {
				width : 220
			},
			defaultType : 'textfield',

			items : [{
				fieldLabel : '友情链接名称',
				name : 'link.url',
				id:'linkUrlUpdate',
				allowBlank : false
			}, {
				fieldLabel : '提示字符串',
				name : 'link.tooltip',
				id:'linkTooltipUpdate',
				allowBlank : false
			}, {
				fieldLabel : '添加时间',
				name : 'link.createDate',
				id:'linkDateUpdate',
				allowBlank : false
			}]
		});
		
		var jsonObject;
		Ext.Ajax.request( {
			url : basePath + 'link/load.action?link.id=' + linedata.json.id,
			method : 'post',
			callback : function(op, success, response) {
				var jsonObject = eval('(' + response.responseText + ')');
				Ext.getCmp("linkUrlUpdate").setValue(jsonObject.url);
    			Ext.getCmp("linkTooltipUpdate").setValue(jsonObject.tooltip);
    			Ext.getCmp("linkDateUpdate").setValue(jsonObject.createDate);
			}
		});
		
	    var imagesPanel = new Ext.Panel({
	        title:'友情链接图片',
	        region:'east',
	        layout:'vbox',
			split : true,
			frame : true,
			maxWidth : 210,
			minWidth : 210,
			width:210,
			autoScroll:true,
			collapsible : true,
			collapseMode: 'mini',
	        items: new Ext.DataView({
		        itemSelector: 'div.thumb-wrap',
		        style:'overflow:auto',
		        multiSelect: true,
		        width:'100%',
		        height:'100%',
		        store: new Ext.data.JsonStore({
				    url: basePath + 'link/image.action?imageName=' + linedata.json.image.name,
				    root: 'image',
			        storeId:'linkImagesStore',
				    autoLoad:true,
				    fields: ['name', 'path', 'id']
				}),
		        tpl: new Ext.XTemplate(
		            '<tpl for=".">',
		            '<div class="thumb-wrap" id="{name}">',
		            '<div class="thumb"><img src="' + basePath + '{path}"' +
		            ' width=180>' +
		            '</div></div>',
		            '</tpl>'
		        )
		    })
	    });
		
		Ext.apply(this, {
			title: "查看友情链接信息",
	        plain: true,
	        width:600,
	        height:300,
	        modal: true,
	        maximizable:true,
	        border: false,
	        layout: 'border',
	        autoScroll:true,
	        items: [modifyForm, imagesPanel]
		});
		Ext.ux.ViewLink.superclass.initComponent.apply(this, arguments);
	}
});
Ext.reg('lgnViewLink', Ext.ux.ViewLink);
